<template>
  <div class="index">
    <div class="topBar">
      <router-link to="/NavPage"  class="iconfont icon-daohangliebiao navIcon fl"></router-link>
    </div>
    <div class="searchBar por">
      <input type="text" class="searchInput" placeholder="请输入书籍名称">
      <span class="icon-search iconsearch poa iconfont"></span>
      <van-button size="large">大号按钮</van-button>
    </div>
    <!--swipwer area-->
    <div class="swiper-area banner">
        <van-swipe :autoplay="1000">
            <van-swipe-item v-for="(banner,index) in bannerPicArray" :key="index">
                <img :src="banner.imageUrl" width="100%"/>
            </van-swipe-item>
        </van-swipe>
    </div>
    <div class="content">
      <div class="lists">
        <div class="article clearfix por" v-for="(item,index) in lists" :key="index">
          <router-link to="/CrowdFunding">
            <img src="https://ss0.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=339300033,2872340583&fm=58&w=227&h=340&img.JPEG" alt="" class="pic">
            <div class="info">
              <p class="tit">{{item.bookname}}</p>
              <div class="author">
                作者：{{item.author}}
              </div>
              <div class="txt">
                作品简介：{{item.summary}}
              </div>
            </div>
          </router-link>
          <i></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import url from "@/serviceAPI.config.js";
export default {
  name: "index",
  data() {
    return {
      lists: "",
      images: [
        "http://img.17k.com/cmsimg/default/2017/640-170/2720470-640-170.jpg",
        "http://img.17k.com/cmsimg/default/2017/640-170/h5-quanzhanbao.jpg",
        "http://img.17k.com/cmsimg/default/2017/640-170/2785153-640-170.jpg"
      ],
      bannerPicArray:[
                {imageUrl:'http://7xjyw1.com1.z0.glb.clouddn.com/simleVueDemoPic001.jpg'},
                {imageUrl:'http://7xjyw1.com1.z0.glb.clouddn.com/simleVueDemoPic002.jpg'},
                {imageUrl:'http://7xjyw1.com1.z0.glb.clouddn.com/simleVueDemoPic003.jpg'},
            ]
    };
  },
  created() {
    if (
      window.localStorage.getItem("Openid") == "undefined" ||
      !window.localStorage.getItem("Openid")
    ) {
      if (this.$route.query.openid != "" && this.$route.query.openid != "") {
        window.localStorage.setItem("Openid", this.$route.query.openid);
      }
    }
    axios({
      url: url.bookList + "?index=" + 1 + "&size=" + 10,
      methods: "get"
    })
      .then(reponse => {
        if (reponse.status == 200) {
          if (reponse.data.Data) {
            this.lists = reponse.data.Data;
          }
        }
      })
      .catch(error => {
        alert("网络错误，请稍后再试");
      });
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.index {
  background: #f5efef !important;
  /* padding: 0 0; */
  height: 100%;
  position: fixed;
  width: 100%;
  overflow: scroll;
  transform: translateZ(0);
  width: 7.5rem;
  margin: 0 auto;
}
.searchBar {
  width: 6rem;
  height: 0.7rem;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: left;
  -ms-flex-pack: left;
  justify-content: left;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  margin: 0.2rem auto 0;
}
.searchInput {
  width: 6rem;
  height: 0.7rem;
  color: #333;
  display: block;
  text-align: left;
  border-radius: 0.1rem;
  border: 0.02rem solid #eee;
  margin: 0.2rem auto;
  background: #fff;
  text-indent: 0.65rem;
}

.iconsearch {
  font-size: 0.3rem;
  color: #333;
  margin-left: 0.2rem;
}
.banner,
.banner img {
  width: 7.5rem;
  height: 2.79rem;
  max-height: 2.79rem;
  overflow: hidden;
}
.banner img {
  width: 7.5rem;
  height: 2.5rem;
}
.content {
  margin-top: 0.6rem;
}
.lists .article {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  margin-bottom: 0.3rem;
}
.article a {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
  height: 100%;
}
.article .pic {
  width: 2.2rem;
  height: 2.2rem;
}
.article .info {
  margin-left: 0.4rem;
  margin-top: 0.25rem;
}
.article .info .tit {
  font-size: 0.34rem;
}
.article .info .author {
  margin: 0.1rem 0;
}
.article .info .txt {
  height: 1.6rem;
  width: 4rem;
  text-overflow: ellipsis;
  overflow: hidden;
  /* word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical; */
}
.navIcon {
  position: fixed;
  left: 0.2rem;
  top: 0.2rem;
  z-index: 3;
  font-size: 0.6rem;
  color: #333;
  display: block;
}
.topBar p {
  font-size: 0.5rem;
  color: #333;
  text-align: center;
  margin-top: 0.3rem;
}
.article i {
  display: block;
  position: absolute;
  left: 6.5rem;
  top: 0.2rem;
  width: 0.2rem;
  height: 0.2rem;
  border-radius: 50%;
  background: #f00;
}
</style>
